package com.thread;

import java.util.concurrent.TimeUnit;

public class Special_ThreadLocal_27 {

    static class Person{
        String name = "zs";
    }

    static ThreadLocal<Person> tl = new ThreadLocal<>();
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(tl.get());
        },"t1");

        Thread t2 = new Thread(()->{

            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            tl.set(new Person());

        },"t2");

        t2.start();
        t1.start();
    }
}
